<template>
  <command :name="command">
    <icon :type="iconType" :title="text" />
    <span v-if="label">{{ label }}</span>
  </command>
</template>

<script>
import { Command } from 'vue-flowchart-editor'
import Icon from './Icon'

export default {
  name: 'EditorToolbarButton',

  components: {
    Command,
    Icon
  },
  // 父组件通过v-bind向子组件传值，子组件通过props来获取父组件传递过来的值，被引用的就是子组件
  props: ['command', 'icon', 'text', 'label'],

  computed: {
    iconType() {
      return `icon${this.icon || this.command}`
    }
  }
}
</script>
